package pers.mihao.quickstream.start;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

/**
 * <p>
 *     代码生成器
 * </p>
 */
public class MpGenerator {

    public static void main(String[] args) throws InterruptedException {

        //用来获取Mybatis-Plus.properties文件的配置信息
        final ResourceBundle rb = ResourceBundle.getBundle("mybatis-plus");

        FastAutoGenerator.create(new DataSourceConfig.Builder(rb.getString("url"), rb.getString("userName"),
                rb.getString("password")))
                .globalConfig(builder -> builder.outputDir(rb.getString("OutputDir"))
                        .author(rb.getString("author")))
                .packageConfig(builder -> builder.parent(rb.getString("parent"))
                        .entity("repository.domain")
                        .mapper("repository.mapper"))
                .templateEngine(new FreemarkerTemplateEngine())
                .strategyConfig(builder -> builder.addInclude(rb.getString("tableName").split(","))
                        .addTablePrefix("tb"))
                .execute();
    }
}

